package org.jeecg.modules.mobile.controller;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.util.BeanUtil;
import org.jeecg.modules.basic.material.entity.BasicMaterial;
import org.jeecg.modules.basic.material.mapper.BasicMaterialMapper;
import org.jeecg.modules.basic.material.service.IBasicMaterialService;
import org.jeecg.modules.basic.print.entity.PrintConfig;
import org.jeecg.modules.basic.print.entity.WmsDocumentTypeStatus;
import org.jeecg.modules.basic.print.service.IPrintConfigService;
import org.jeecg.modules.basic.warehouse.entity.WmsBasicWarehouse;
import org.jeecg.modules.basic.warehouse.entity.WmsBasicWarehouseArea;
import org.jeecg.modules.basic.warehouse.entity.WmsBasicWarehouseAreaLocation;
import org.jeecg.modules.basic.warehouse.service.IWmsBasicWarehouseAreaLocationService;
import org.jeecg.modules.basic.warehouse.service.IWmsBasicWarehouseAreaService;
import org.jeecg.modules.business.doc.business.entity.WmsInReceipt;
import org.jeecg.modules.business.doc.outbound.entity.WmsOutReceipt;
import org.jeecg.modules.business.doc.outbound.entity.dto.ListByOutboundIdResponseVO;
import org.jeecg.modules.business.doc.outbound.entity.vo.OutboundReceiptLoadCheckFullVO;
import org.jeecg.modules.business.doc.outbound.service.IWmsOutReceiptService;
import org.jeecg.modules.business.outbound.entity.WmsOutReceiptTask;
import org.jeecg.modules.business.outbound.entity.WmsOutReceiptTaskMaterial;
import org.jeecg.modules.business.outbound.entity.vo.OutboundTaskUnPickVO;
import org.jeecg.modules.business.outbound.service.IWmsOutReceiptTaskMaterialService;
import org.jeecg.modules.business.outbound.service.IWmsOutReceiptTaskService;
import org.jeecg.modules.business.repertory.entity.WmsRepertory;
import org.jeecg.modules.business.takestockplan.entity.TakeStockPlanExecuteMaterial;
import org.jeecg.modules.business.takestockplan.entity.VO.TakeStockPlanExecuteMaterialVO;
import org.jeecg.modules.business.takestockplan.service.ITakeStockPlanExecuteService;
import org.jeecg.modules.business.warehouse.entity.WmsInReceiptTask;
import org.jeecg.modules.business.warehouse.entity.WmsInReceiptTaskMaterial;
import org.jeecg.modules.business.warehouse.entity.vo.ListByMaterialIdOutVO;
import org.jeecg.modules.business.warehouse.entity.vo.ListByMaterialIdResponseVO;
import org.jeecg.modules.business.warehouse.service.IWmsInReceiptTaskMaterialService;
import org.jeecg.modules.business.warehouse.service.IWmsInReceiptTaskService;
import org.jeecg.modules.flow.callback.enums.InboundStatusEnum;
import org.jeecg.modules.mobile.entity.vo.*;
import org.jeecg.modules.mobile.service.IMobileMyTaskService;
import org.jeecg.modules.system.security.DictQueryBlackListHandler;
import org.jeecg.modules.system.service.ISysDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @Description: 移动端-首页
 * @Author: jeecg-boot
 * @Date: 2023-08-24
 * @Version: V1.0
 */
@Api(tags = "移动端-首页")
@RestController
@RequestMapping("/mobile/myTask")
@Slf4j
public class MobileHomePageController {

    @Autowired
    private IMobileMyTaskService mobileMyTaskService;

    @Autowired
    private DictQueryBlackListHandler dictQueryBlackListHandler;

    @Autowired
    private ISysDictService sysDictService;

    @Autowired
    private IWmsInReceiptTaskService wmsInReceiptTaskService;

    @Autowired
    private IWmsOutReceiptTaskService wmsOutReceiptTaskService;

    @Autowired
    private IWmsOutReceiptService wmsOutReceiptService;

    @Autowired
    private IWmsInReceiptTaskMaterialService wmsInReceiptTaskMaterialService;
    @Autowired
    private IWmsOutReceiptTaskMaterialService wmsOutReceiptTaskMaterialService;

    @Resource
    private BasicMaterialMapper basicMaterialMapper;

    @Autowired
    private ITakeStockPlanExecuteService takeStockPlanExecuteService;

    @Autowired
    private IWmsBasicWarehouseAreaService wmsBasicWarehouseAreaService;

    @Autowired
    private IWmsBasicWarehouseAreaLocationService wmsBasicWarehouseAreaLocationService;
    @Autowired
    private IPrintConfigService iPrintConfigService;
    @Autowired
    private IBasicMaterialService iBasicMaterialService;

    /**
     * 根据批次号查询物料信息
     */
    @ApiOperation(value = "根据批次号查询物料信息", notes = "根据批次号查询物料信息")
    @GetMapping("/getMaterialByBatch")
    public Result<BasicMaterial> getMaterialByBatch(@ApiParam("入库任务id") String wmsInReceiptTaskId, @ApiParam("批次号") String batchCode) {
        return Result.OK(mobileMyTaskService.getMaterialByBatch(wmsInReceiptTaskId, batchCode));
    }

    /**
     * 查询任务列表
     */
    @ApiOperation(value = "查询任务列表", notes = "查询任务列表")
    @GetMapping("/getMyTask")
    public Result<List<MobileMyTaskVO>> getMyTask(@ApiParam("仓库id") String warehouseId, @ApiParam("任务状态，1:待执行, 2:执行中, 3:已完成") String status) {
        return Result.OK(mobileMyTaskService.listMyTask(warehouseId, status));
    }

    /**
     * 查询仓库
     */
    @ApiOperation(value = "查询仓库", notes = "查询仓库")
    @GetMapping("/getWarehouse")
    public Result<List<WmsBasicWarehouse>> getWarehouse(@ApiParam("用户id") String userId) {
        return Result.OK(mobileMyTaskService.getWarehouse(userId));
    }

    /**
     * 首页统计数据
     */
    @ApiOperation(value = "首页统计数据", notes = "首页统计数据")
    @GetMapping("/homePage")
    public Result<MobileHomePageVO> homePage(@ApiParam("用户id") String userId, @ApiParam("仓库id") String warehouseId) {
        return Result.OK(mobileMyTaskService.getHomePage(userId, warehouseId));
    }

    /**
     * 查询单据列表
     */
    @ApiOperation(value = "查询单据列表", notes = "查询单据列表")
    @GetMapping("/getMyDocument")
    public Result<List<MobileMyDocumentVO>> getMyDocument(@ApiParam("仓库id") String warehouseId, @ApiParam("类型,1: 入库单, 2: 出库单, 3: 移库单") String type) {
        return Result.OK(mobileMyTaskService.listMyDocument(warehouseId, type));
    }

    /**
     * 获取字典数据 【接口签名验证】
     *
     * @param dictCode 字典code
     * @param dictCode 表名,文本字段,code字段  | 举例：sys_user,realname,id
     * @return
     */
    @ApiOperation(value = "获取字典数据", notes = "获取字典数据")
    @RequestMapping(value = "/sys/dict/getDictItems/{dictCode}", method = RequestMethod.GET)
    public Result<List<DictModel>> getDictItems(@PathVariable("dictCode") String dictCode) {
        log.info(" dictCode : " + dictCode);
        Result<List<DictModel>> result = new Result<List<DictModel>>();
        //update-begin-author:taoyan date:20220317 for: VUEN-222【安全机制】字典接口、online报表、online图表等接口，加一些安全机制
        if (!dictQueryBlackListHandler.isPass(dictCode)) {
            return result.error500(dictQueryBlackListHandler.getError());
        }
        //update-end-author:taoyan date:20220317 for: VUEN-222【安全机制】字典接口、online报表、online图表等接口，加一些安全机制
        try {
            List<DictModel> ls = sysDictService.getDictItems(dictCode);
            if (ls == null) {
                result.error500("字典Code格式不正确！");
                return result;
            }
            result.setSuccess(true);
            result.setResult(ls);
            log.debug(result.toString());
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            result.error500("操作失败");
            return result;
        }
        return result;
    }

    /**
     * 库存查询
     */
    @ApiOperation(value = "库存查询", notes = "库存查询")
    @PostMapping("/queryRepertory")
    public Result<IPage<WmsRepertory>> queryRepertory(@RequestBody MobileRepertoryParamVO vo) {
        Result<IPage<WmsRepertory>> result = new Result<>();
        Page<WmsRepertory> pageList = new Page<>(vo.getPageNo(), vo.getPageSize());
        result.setSuccess(true);
        result.setResult(mobileMyTaskService.queryRepertory(pageList, vo));
        return result;
    }

    /**
     * 入库任务出库任务小红点
     */
    @ApiOperation(value = "入库任务出库任务小红点", notes = "入库任务出库任务小红点")
    @GetMapping("/getRedNum")
    public Result<HashMap<String, Object>> getRedNum(@ApiParam("仓库id") String warehouseId) {
        return Result.OK(mobileMyTaskService.getRedNum(warehouseId));
    }

    /**
     * 任务查询
     */
    @ApiOperation(value = "任务查询", notes = "任务查询")
    @GetMapping("/queryTask")
    public Result<Page<MobileMyTaskVO>> queryTask(MobileTaskParamVO vo,
                                                  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                                  @RequestParam(name="pageSize", defaultValue="5") Integer pageSize) {
        Result<Page<MobileMyTaskVO>> result = new Result<>();
        Page<MobileMyTaskVO> pageList = new Page<>(pageNo, pageSize);
        pageList = mobileMyTaskService.queryTask(pageList, vo);
        if (CollectionUtils.isEmpty(pageList.getRecords())) {
            result.setMessage("根据当前筛选条件和查询条件，查询不到任务");
        }
        result.setSuccess(true);
        result.setResult(pageList);
        return result;
    }

    /**
     * 任务查询
     */
    @ApiOperation(value = "任务查询", notes = "任务查询")
    @PostMapping("/queryTask")
    public Result<Page<MobileMyTaskVO>> queryTask(@RequestBody MobileTaskParamVO vo) {
        Result<Page<MobileMyTaskVO>> result = new Result<>();
        Page<MobileMyTaskVO> pageList = new Page<>(vo.getPageNo(), vo.getPageSize());
        pageList = mobileMyTaskService.queryTask(pageList, vo);
        if (CollectionUtils.isEmpty(pageList.getRecords())) {
            result.setMessage("根据当前筛选条件和查询条件，查询不到任务");
        }
        result.setSuccess(true);
        result.setResult(pageList);
        return result;
    }

    /**
     * 扫码查询库区库位
     */
    @ApiOperation(value = "扫码查询库区库位", notes = "扫码查询库区库位")
    @GetMapping("/queryWarehouse")
    public Result<MobileWarehouseVO> queryWarehouse(@ApiParam("库区或库位名称") String name, @ApiParam("仓库id") String warehouseId) {
        return Result.OK(mobileMyTaskService.queryWarehouse(name, warehouseId));
    }

    /**
     * 查询所有状态
     */
    @ApiOperation(value = "查询所有状态", notes = "查询所有状态")
    @GetMapping("/queryAllStatus")
    public Result<List<WmsDocumentTypeStatus>> queryAllStatus(@ApiParam("类型, document_task 入库任务, outbound_task 出库任务, move_type 移库, take_job 盘点作业") String type) {
        return Result.OK(mobileMyTaskService.queryAllStatus(type));
    }

    /**
     * 查询入库任务详情
     */
    @ApiOperation(value = "查询入库任务详情", notes = "查询入库任务详情")
    @GetMapping("/inReceiptTask/queryById")
    public Result<List<WmsInReceiptTask>> queryInById(String id) {
        WmsInReceiptTask wmsInReceiptTask = wmsInReceiptTaskService.getById(id);
        if (wmsInReceiptTask == null) {
            return Result.error("未找到对应数据");
        }
        List<WmsInReceiptTask> list = new ArrayList<>();
        list.add(wmsInReceiptTask);
        return Result.OK(list);
    }

    /**
     * 创建入库单时扫码查询待入库物料
     */
    @ApiOperation(value = "创建入库单时扫码查询待入库物料", notes = "创建入库单时扫码查询待入库物料")
    @GetMapping("/inReceipt/queryByName")
    public Result<List<ListByMaterialIdResponseVO>> queryByName(@ApiParam("批次号或物料编码或钢卷号") String name, @ApiParam("入库任务id") String inReceiptTaskId) {
        List<WmsInReceiptTaskMaterial> wmsInReceiptTaskMaterialList = wmsInReceiptTaskMaterialService.selectByMainId(inReceiptTaskId);
        List<ListByMaterialIdResponseVO> list = BeanUtil.copyToList(wmsInReceiptTaskMaterialList, ListByMaterialIdResponseVO.class);
        //过滤掉全部入库的
        list = list.stream().filter(s->!Objects.equals(s.getWarehouseStatus(), InboundStatusEnum.ALL.getCode())).collect(Collectors.toList());
        List<String> materialIds = list.stream().map(ListByMaterialIdResponseVO::getWmsBasicMaterialId).collect(Collectors.toList());
        List<BasicMaterial> basicMaterials = basicMaterialMapper.selectList(new LambdaQueryWrapper<BasicMaterial>()
                .in(CollectionUtil.isNotEmpty(materialIds), BasicMaterial::getId, materialIds));
        for (ListByMaterialIdResponseVO vo : list) {
            basicMaterials.forEach(basicMaterial -> {
                if (basicMaterial.getId().equals(vo.getWmsBasicMaterialId())) {
                    if (ObjectUtil.isNotEmpty(basicMaterial)) {
                        vo.setMaterialCode(basicMaterial.getCode());
                        vo.setMaterialName(basicMaterial.getName());
                        vo.setSpecification(basicMaterial.getSpecification());
                    }
                }
            });
        }
        if (StringUtils.isNotBlank(name)) {
            list = list.stream().filter(a -> name.equals(a.getBatchCode()) || name.equals(a.getMaterialCode()) || name.equals(a.getSteelCoilNumber())).collect(Collectors.toList());
        }
        //在此判断单据是否配置了出入库物料可不存在与任务中
        WmsInReceiptTask task = wmsInReceiptTaskService.getById(inReceiptTaskId);
        if (task != null){
            PrintConfig printConfig = iPrintConfigService.getOne(new LambdaQueryWrapper<PrintConfig>()
                    .eq(PrintConfig::getBusinessType, "document_type")
                    .eq(PrintConfig::getDocumentType, task.getDocumentType())
                    .last("limit 1")
            );
            if (printConfig != null){
                //勾选了出入库任务可不存在与任务中,默认传的name是物料编码
                if (Objects.equals(printConfig.getMaterialCanOtherWay(),1)){
                    BasicMaterial basicMaterial = iBasicMaterialService.getOne(new LambdaQueryWrapper<BasicMaterial>()
                            .eq(BasicMaterial::getName, name)
                    );
                    if (basicMaterial != null){
                        List<String> collect = list.stream().map(ListByMaterialIdResponseVO::getMaterialCode).collect(Collectors.toList());
                        if (!collect.contains(basicMaterial.getCode())){
                            ListByMaterialIdResponseVO responseVO = new ListByMaterialIdResponseVO();
                            responseVO.setWmsBasicMaterialId(basicMaterial.getId());
                            responseVO.setMaterialCode(basicMaterial.getCode());
                            responseVO.setMaterialName(basicMaterial.getName());
                            responseVO.setSpecification(basicMaterial.getSpecification());
                            list.add(responseVO);
                        }
                    }
                }
            }
        }
        return Result.OK(list);
    }

    /**
     * 创建出库单时扫码查询待入库物料
     */
    @ApiOperation(value = "创建出库单时扫码查询待出库物料", notes = "创建出库单时扫码查询待出库物料")
    @GetMapping("/outReceipt/getOutByNameAndTaskId")
    public Result<List<ListByMaterialIdOutVO>> getOutByNameAndTaskId(@ApiParam("批次号或物料编码或钢卷号") String name, @ApiParam("出库任务id") String outReceiptTaskId) {
        List<WmsOutReceiptTaskMaterial> wmsInReceiptTaskMaterialList = wmsOutReceiptTaskMaterialService.selectByMainId(outReceiptTaskId);
        List<ListByMaterialIdOutVO> list = BeanUtil.copyToList(wmsInReceiptTaskMaterialList, ListByMaterialIdOutVO.class);
        List<String> materialIds = list.stream().map(ListByMaterialIdOutVO::getWmsBasicMaterialId).collect(Collectors.toList());
        List<BasicMaterial> basicMaterials = basicMaterialMapper.selectList(new LambdaQueryWrapper<BasicMaterial>()
                .in(CollectionUtil.isNotEmpty(materialIds), BasicMaterial::getId, materialIds));
        for (ListByMaterialIdOutVO vo : list) {
            basicMaterials.forEach(basicMaterial -> {
                if (basicMaterial.getId().equals(vo.getWmsBasicMaterialId())) {
                    if (ObjectUtil.isNotEmpty(basicMaterial)) {
                        vo.setMaterialCode(basicMaterial.getCode());
                        vo.setMaterialName(basicMaterial.getName());
                        vo.setSpecification(basicMaterial.getSpecification());
                    }
                }
            });
        }
        if (StringUtils.isNotBlank(name)) {
            list = list.stream().filter(a -> name.equals(a.getBatchCode()) || name.equals(a.getMaterialCode()) || name.equals(a.getSteelCoilNumber())).collect(Collectors.toList());
        }
        return Result.OK(list);
    }

    /**
     * 查询出库任务详情
     */
    @ApiOperation(value = "查询出库任务详情", notes = "查询出库任务详情")
    @GetMapping("/outReceiptTask/queryById")
    public Result<List<WmsOutReceiptTask>> queryOutById(String id) {
        WmsOutReceiptTask wmsOutReceiptTask = wmsOutReceiptTaskService.getById(id);
        if (wmsOutReceiptTask == null) {
            return Result.error("未找到对应数据");
        }
        List<WmsOutReceiptTask> list = new ArrayList<>();
        list.add(wmsOutReceiptTask);
        return Result.OK(list);
    }

    /**
     * 创建出库单时扫码查询待出库物料
     */
    @ApiOperation(value = "创建出库单时扫码查询待出库物料", notes = "创建出库单时扫码查询待出库物料")
    @GetMapping("/outReceipt/queryByName")
    public Result<List<ListByOutboundIdResponseVO>> queryOutByName(@ApiParam("批次号或物料编码") String name, @ApiParam("出库任务id") String outReceiptTaskId) {
        List<ListByOutboundIdResponseVO> list = wmsOutReceiptService.listByOutboundTaskId(outReceiptTaskId);
        if (StringUtils.isNotBlank(name)) {
            list = list.stream().filter(a -> name.equals(a.getBatchCode()) || name.equals(a.getMaterialCode())).collect(Collectors.toList());
        }
        return Result.OK(list);
    }

    /**
     * 查询盘点作业详情
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "查询盘点作业详情", notes = "查询盘点作业详情")
    @GetMapping(value = "/takeStockExecute/queryById")
    public Result<List<TakeStockPlanExecuteMaterialVO>> queryById(@RequestParam(name = "id") String id) {
        List<TakeStockPlanExecuteMaterialVO> list = new ArrayList<>();
        TakeStockPlanExecuteMaterialVO execute = takeStockPlanExecuteService.getExecuteById(id);
        List<TakeStockPlanExecuteMaterial> materialList = execute.getTakeStockPlanExecuteMaterialList();
        for (TakeStockPlanExecuteMaterial material : materialList) {
            if (StringUtils.isNotBlank(material.getWmsBasicWarehouseAreaId())) {
                WmsBasicWarehouseArea area = wmsBasicWarehouseAreaService.getById(material.getWmsBasicWarehouseAreaId());
                material.setWmsBasicWarehouseAreaName(area.getName());
            }
            if (StringUtils.isNotBlank(material.getWmsBasicWarehouseAreaLocationId())) {
                WmsBasicWarehouseAreaLocation location = wmsBasicWarehouseAreaLocationService.getById(material.getWmsBasicWarehouseAreaLocationId());
                material.setWmsBasicWarehouseAreaLocationName(location.getName());
            }
        }
        list.add(execute);
        return Result.OK(list);

    }

    /**
     * 查询入库任务关联入库单列表
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "查询入库任务关联入库单列表", notes = "查询入库任务关联入库单列表")
    @GetMapping(value = "/inReceiptTask/queryInReceipt")
    public Result<List<WmsInReceipt>> queryInReceipt(@RequestParam(name = "id") String id,
                                                     @RequestParam(name = "name", required = false) String name) {
        List<WmsInReceipt> wmsInReceipts = mobileMyTaskService.queryInReceipt(id, name);
        return Result.OK(wmsInReceipts);
    }

    /**
     * 查询出库任务关联出库单列表
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "查询出库任务关联出库单列表", notes = "查询出库任务关联出库单列表")
    @GetMapping(value = "/outReceiptTask/queryOutReceipt")
    public Result<List<WmsOutReceipt>> queryOutReceipt(@RequestParam(name = "id") String id,
                                                       @RequestParam(name = "name", required = false) String name) {
        List<WmsOutReceipt> wmsOutReceiptList = mobileMyTaskService.queryOutReceipt(id, name);
        return Result.OK(wmsOutReceiptList);
    }

    /**
     * 安灯接口
     *
     * @return
     */
    @ApiOperation(value = "安灯接口", notes = "安灯接口")
    @PostMapping(value = "/lightOn")
    public Result<String> lightOn(@RequestBody List<InReceiptStrategyWarehouseVO> list) {
        mobileMyTaskService.lightOn(list);
        return Result.OK();
    }

    /**
     * 安灯接口-单个
     *
     * @return
     */
    @ApiOperation(value = "安灯接口-单个", notes = "安灯接口-单个")
    @PostMapping(value = "/light")
    public Result<String> light(@RequestBody InReceiptStrategyWarehouseVO vo) {
        List<InReceiptStrategyWarehouseVO> list = new ArrayList<>();
        list.add(vo);
        mobileMyTaskService.lightOn(list);
        return Result.OK();
    }

    /**
     * 根据仓库获取库区
     *
     * @return
     */
    @ApiOperation(value = "根据仓库获取库区", notes = "根据仓库获取库区")
    @GetMapping(value = "/getArea")
    public Result<List<WmsBasicWarehouseArea>> getArea(@ApiParam("仓库id") String warehouseId) {
        List<WmsBasicWarehouseArea> list = wmsBasicWarehouseAreaService.list(new LambdaQueryWrapper<WmsBasicWarehouseArea>()
                .eq(WmsBasicWarehouseArea::getWmsBasicWarehouseId, warehouseId)
                .eq(WmsBasicWarehouseArea::getStatus, "1")
                .orderByAsc(WmsBasicWarehouseArea::getId));
        return Result.OK(list);
    }

    /**
     * 根据仓库获取库位
     *
     * @return
     */
    @ApiOperation(value = "根据仓库获取库位", notes = "根据仓库获取库位")
    @GetMapping(value = "/getLocation")
    public Result<List<List<WmsBasicWarehouseAreaLocation>>> getLocation(@ApiParam("仓库id") String warehouseId) {
        List<WmsBasicWarehouseArea> list = wmsBasicWarehouseAreaService.list(new LambdaQueryWrapper<WmsBasicWarehouseArea>()
                .eq(WmsBasicWarehouseArea::getWmsBasicWarehouseId, warehouseId)
                .eq(WmsBasicWarehouseArea::getStatus, "1")
                .orderByAsc(WmsBasicWarehouseArea::getId));
        List<List<WmsBasicWarehouseAreaLocation>> locationList = new ArrayList<>();
        for (WmsBasicWarehouseArea area : list) {
            List<WmsBasicWarehouseAreaLocation> locations = wmsBasicWarehouseAreaLocationService.list(new LambdaQueryWrapper<WmsBasicWarehouseAreaLocation>()
                    .eq(WmsBasicWarehouseAreaLocation::getWmsBasicWarehouseAreaId, area.getId())
                    .eq(WmsBasicWarehouseAreaLocation::getStatus, "1"));
            locationList.add(locations);
        }
        return Result.OK(locationList);
    }

    /**
     * 查询仓库是否有默认库区
     *
     * @return
     */
    @ApiOperation(value = "查询仓库是否有默认库区", notes = "查询仓库是否有默认库区")
    @GetMapping(value = "/getDefaultArea")
    public Result<WmsBasicWarehouseArea> getDefaultArea(@ApiParam("仓库id") String warehouseId) {
        return Result.OK(mobileMyTaskService.getDefaultArea(warehouseId));
    }

    /**
     * 入库扫托盘码
     *
     * @return
     */
    @ApiOperation(value = "入库扫托盘码", notes = "入库扫托盘码")
    @GetMapping(value = "/inTrayCode")
    public Result<List<ListByMaterialIdResponseVO>> inTrayCode(@ApiParam("任务id") String taskId,
                                                               @ApiParam("托盘码") String code) {
        return Result.OK(mobileMyTaskService.inTrayCode(taskId, code));
    }

    /**
     * 出库扫托盘码
     *
     * @return
     */
    @ApiOperation(value = "出库扫托盘码", notes = "出库扫托盘码")
    @GetMapping(value = "/outTrayCode")
    public Result<List<ListByMaterialIdOutVO>> outTrayCode(@ApiParam("任务id") String taskId,
                                                           @ApiParam("托盘码") String code) {
        return Result.OK(mobileMyTaskService.outTrayCode(taskId, code));
    }

    /**
     * 移库扫托盘码
     *
     * @return
     */
    @ApiOperation(value = "移库扫托盘码", notes = "移库扫托盘码")
    @GetMapping(value = "/moveTrayCode")
    public Result<List<WmsRepertory>> moveTrayCode(@ApiParam("托盘码") String code) {
        return Result.OK(mobileMyTaskService.moveTrayCode(code));
    }

    /**
     * 拣货扫托盘码
     *
     * @return
     */
    @ApiOperation(value = "拣货扫托盘码", notes = "拣货扫托盘码")
    @GetMapping(value = "/pickTrayCode")
    public Result<List<OutboundTaskUnPickVO>> pickTrayCode(@ApiParam("出库任务id") String taskId,
                                                           @ApiParam("托盘码") String code) {
        return Result.OK(mobileMyTaskService.pickTrayCode(taskId, code));
    }

    /**
     * 装车复核扫托盘码
     *
     * @return
     */
    @ApiOperation(value = "装车复核扫托盘码", notes = "装车复核扫托盘码")
    @GetMapping(value = "/checkTrayCode")
    public Result<List<OutboundReceiptLoadCheckFullVO>> checkTrayCode(@ApiParam("出库单id") String taskId,
                                                                      @ApiParam("托盘码") String code,
                                                                      @ApiParam("车牌") String carNumber) {
        return Result.OK(mobileMyTaskService.checkTrayCode(taskId, code, carNumber));
    }
}
